﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyKTVDao;
using MeadiePlayer;

namespace MedioPalyer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ChangeMenu();
        }
        SongInfoDao dao = new SongInfoDao();
        private void ChangeMenu()
        {

            string sql = "select * from song_info";
           List<SongInfoEntity> list =  dao.QuerySongListBySql(sql,null);
            //提取数据库歌曲集合

            //生成lable控件
            for (int i = 0; i < list.Count; i++)
            {
                Label label = new Label();
                label.Text = list[i].Name;
                label.Cursor =  System.Windows.Forms.Cursors.Hand;
                label.AutoSize = true;
                label.Tag = list[i];
                label.Location = new System.Drawing.Point(50, 50+(i*30));
                label.Size = new System.Drawing.Size(41, 12);
                label.TabIndex = 1;
                //绑定方法
                label.Click += ChangeSong;
                this.Controls.Add(label); 
            }
           
        }

        private void ChangeSong(object sender, EventArgs e)
        {
            Label label = (Label)sender;
            SongInfoEntity song = (SongInfoEntity)label.Tag;
            MessageBox.Show(song.Name);
        }
    }
}
